package com.laoyao.util;
import com.jfinal.kit.PropKit;
import com.laoyao.entity.Button;
import com.laoyao.entity.CommonButton;
import com.laoyao.entity.ComplexButton;
import com.laoyao.entity.Menu;
import com.laoyao.entity.Token;
import com.laoyao.entity.ViewButton;


public class MenuMain {
	public static void main(String[] args) {	

		
          // 第三方用户唯一凭证
		// 调用接口获取access_token
		PropKit.use("a_little_config.txt");
		Token at = abc.getToken(PropKit.get("appid"),PropKit.get("appsecret"));
		if (null != at) {
			boolean result = MenuUtil.createMenu(getMenu(), at.getAccessToken());
			 //判断菜单创建结果
			if (result)
				System.out.println("菜单创建成功！");
			else
				System.out.println("菜单创建失败，错误码：" + result);
		}
	}

	/**
	 * 组装菜单数据
	 * 
	 * @return
	 */
	private static Menu getMenu() {
		
		PropKit.use("a_little_config.txt");
		
		String str="http://wwww.taojinshang.cn/taojin/weix/index";
		ViewButton btn1 = new ViewButton();
		btn1.setName("商家合作");
		btn1.setType("view");
		btn1.setUrl(str); 
		
		str="http://wwww.taojinshang.cn/taojin/weix/person";	
		ViewButton btn2 = new ViewButton();
		btn2.setName("个人中心");
		btn2.setType("view");
		btn2.setUrl(str); 
		
		str="http://wwww.taojinshang.cn/taojin/WeChat/";
		ViewButton btn3 = new ViewButton();
		btn3.setName("淘金商城");
		btn3.setType("view");
		btn3.setUrl(str); 
		
		str="http://v1.rabbitpre.com/m/YRYv62bUj";
		ViewButton btn4 = new ViewButton();
		btn4.setName("公司简介");
		btn4.setType("view");
		btn4.setUrl(str); 
		
		str="http://wwww.taojinshang.cn/taojin/finance";
		ViewButton btn5 = new ViewButton();
		btn5.setName("金融模块");
		btn5.setType("click");
		btn5.setType("view");
		btn5.setUrl(str); 
		
		str="http://wwww.taojinshang.cn/taojin/marriage";
		ViewButton btn6 = new ViewButton();
		btn6.setName("相亲模块");
		btn6.setType("click");
		btn6.setType("view");
		btn6.setUrl(str); 
		

		
		
		str="http://mp.weixin.qq.com/s/M7I3Q_Y6dcH6scLkB5VmNA";
		ViewButton btn14 = new ViewButton();
		btn14.setName("翔韵简介");
		btn14.setType("view");
		btn14.setUrl(str);
		
		
		str="http://mp.weixin.qq.com/s/UThzh2NeqUYk8z3nRauE3w";
		ViewButton btn21 = new ViewButton();
		btn21.setName("联系我们");
		btn21.setType("view");
		btn21.setUrl(str); 
		
		str="http://mp.weixin.qq.com/s/UThzh2NeqUYk8z3nRauE3w";
		ViewButton btn22 = new ViewButton();
		btn22.setName("社区留言");
		btn22.setType("view");
		btn22.setUrl(str);
		
		str="https://mp.weixin.qq.com/s/kqNi0oyobfLdhA029FClHQ";
		ViewButton btn23 = new ViewButton();
		btn23.setName("商家录单流程");
		btn23.setType("view");
		btn23.setUrl(str);
		
		str="https://mp.weixin.qq.com/s?__biz=MzI3NTM3MDA0MA==&tempkey=i6CyQlbZEJD%2BzOOvY%2BXJAmR571mMY5jeq%2FKw6zrTB6%2BAgY8SkNifzd6Q%2BIMcaHdG%2FVVoZO8ucjiiT74YwghtRCwQg8%2F6lftuq5yGx6BWgdHAYIRMiB9%2BxK92I72FR4oucTvcZfwCq3ILU289EMnDeA%3D%3D&chksm=6b049d195c73140f09856089fbaf07985e496b5bb55dd3d5c376d5b76fd24e6117eedc9bcd9e#rd";
		ViewButton btn24 = new ViewButton();
		btn24.setName("APP下载流程");
		btn24.setType("view");
		btn24.setUrl(str);
		
		
		str="http://ddt.wanxidi.com/ddt/img/logo.jpg";
		ViewButton btn31 = new ViewButton();
		btn31.setName("二维码");
		btn31.setType("view");
		btn31.setUrl(str);
		
		CommonButton btn32 = new CommonButton();
		btn32.setName("联系我们");
		btn32.setType("click");
		btn32.setKey("lxwm");
		
		str="https://mp.weixin.qq.com/s/CBDy4XeMrWosPQzxiWkXTQ";
		ViewButton btn33 = new ViewButton();
		btn33.setName("提现公告");
		btn33.setType("view");
		btn33.setUrl(str);
		
		str="https://mp.weixin.qq.com/s/XxUcQxFeWcJ2t_vEkUmIxA";
		ViewButton btn34 = new ViewButton();
		btn34.setName("常见问题");
		btn34.setType("view");
		btn34.setUrl(str);
		
//		str="https://mp.weixin.qq.com/s/CBDy4XeMrWosPQzxiWkXTQ";
//		ViewButton btn35 = new ViewButton();
//		btn35.setName("提现公告");
//		btn35.setType("view");
//		btn35.setUrl(str);

	
		ComplexButton mainBtn1 = new ComplexButton();
		mainBtn1.setName("商家合作");
		mainBtn1.setSub_button(new Button[] {btn1,btn4,btn5,btn6});

		ComplexButton mainBtn2 = new ComplexButton();
		mainBtn2.setName("个人中心");
		mainBtn2.setSub_button(new Button[] {});

		ComplexButton mainBtn3 = new ComplexButton();
		mainBtn3.setName("我要推广");
		mainBtn3.setSub_button(new  Button[] {btn4,btn5});

		Menu menu = new Menu();
		menu.setButton(new Button[] { mainBtn1, btn2,btn3});
		//menu.setButton(new Button[]{btn11,btn12,btn13} );
		System.out.println(menu);
		return menu;
	}
}
